import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';

class HLCachedImage {
  /*
   * 图片剪切
   * */
  static imageClipOval(String url, {double radius = 80}) {
    return ClipOval(
      child: imageGet(url, width: radius, height: radius),
    );
  }

  /*
   * 图片
   * */
  static imageGet(String url, {double width = 80, double height = 80}) {
    return CachedNetworkImage(
      width: width,
      height: height,
      fit: BoxFit.cover,
      imageUrl: url,
      progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator(value: downloadProgress.progress),
      errorWidget: (context, url, error) => const Icon(Icons.error, color: Colors.blueGrey),
    );
  }
}
